package lab03.test05;

import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Test05 {
    public static void main(String[] args) {

        File file = new File("D:\\dev\\sctu-java-2017-1\\1606101016杨金鸿\\src\\lab05\\test05\\hello.txt");
        FileWriter fileWriter = null;
        FileReader fileReader = null;

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String string = sc.next();

        char[] b = string.toCharArray();
        char[] a = new char[b.length];
        for (int i = 0;i < b.length;i ++){
            a[i] = (char) ((int)b[i] + 1);
        }
        System.out.println(a);

        try {
            fileWriter = new FileWriter(file);
            fileReader = new FileReader(file);
            fileWriter.write(Arrays.toString(a));

            int data = 0;
            while ((data = fileReader.read()) != -1){
                System.out.println((char) data);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
